package com.my.bootvue.config;
import com.my.bootvue.Interceptors.LoginInterceptors;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
 * @author peanut
 * 该注解标志着全面接管springmvc的配置
 * springboot的自动配置失效 一般不会使用
 */
@Configuration
public class WebMvcAdapter implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/login").setViewName("login");
        registry.addViewController("/success").setViewName("success");
        registry.addViewController("/good").setViewName("success");
        registry.addViewController("/main").setViewName("dashboard");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptors())
                .addPathPatterns("/**")
                .excludePathPatterns("/", "/login",
                        "/user/login","/**/*.css", "/**/*.js", "/**/*.svg");
    }
}
